package zr214018d1103;

import java.util.Random;
import java.util.Scanner;

public class playgame {
    static int a = 0;  //记录胜局
    static int b = 0;  //记录平局

    public static void main(String[] args) {
        System.out.println("--------------剪刀石头布小游戏---------------");
        System.out.println("输入1是剪刀·输入2是石头·输入3是布");
        Scanner sc = new Scanner(System.in);
        // 进行5轮游戏
        for (int i = 1; i <= 5; ++i) {
            System.out.println("Round: " + i);
            System.out.print("你出的是：");
            String choose = sc.next();
            int num = new Random().nextInt(3) + 1;
            if (choose.equals("剪刀")) {
                if (num == 1) {
                    System.out.println("电脑出的是：剪刀");
                    System.out.println("平局");
                    b++;
                } else if (num == 2) {
                    System.out.println("电脑出的是：石头");
                    System.out.println("你输了!");
                } else {
                    System.out.println("电脑出的是：布");
                    System.out.println("你赢了!");
                    a++;
                }
            }
            else if (choose.equals("石头")) {
                if (num == 1) {
                    System.out.println("电脑出的是：剪刀");
                    System.out.println("你赢了!");
                    a++;
                } else if (num == 2) {
                    System.out.println("电脑出的是：石头");
                    System.out.println("平局");
                    b++;
                } else {
                    System.out.println("电脑出的是：布");
                    System.out.println("你输了!");
                }
            } else {
                if (num == 1) {
                    System.out.println("电脑出的是：剪刀");
                    System.out.println("你输了!");
                } else if (num == 2) {
                    System.out.println("电脑出的是：石头");
                    System.out.println("你赢了!");
                    a++;
                } else {
                    System.out.println("电脑出的是：布");
                    System.out.println("平句");
                    b++;
                }
            }
        }
        int c = 5 - a - b;
        System.out.println("电脑赢了" + c + "局");
        System.out.println("你总共赢了" + a + "局，" + "平了" + b + "局");
        if (a == c) {
            System.out.println("结果为平局");
        } else if (a > b) {
            System.out.println("结果你赢了！");
        } else System.out.println("结果你输了！");
    }
}

